package com.huawei.appgallery.forum.cards.card;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout.LayoutParams;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView.s;
import com.huawei.appgallery.forum.base.card.ForumCard;
import com.huawei.appgallery.forum.base.card.bean.Section;
import com.huawei.appgallery.forum.cards.bean.ForumFollowCardBean;
import com.huawei.appgallery.forum.cards.bean.ForumHorizonListCardBean;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import o.ayy;
import o.azb;
import o.bsy.c;
import o.bsy.e;
import o.cgz;
import o.ContentManager;
import o.epv;
import o.MinimumFactory;

public class ForumHorizonListCard extends ForumHorizonCard {
    private int ʻ;
    private View ʽ;

    class b extends a {
        final /* synthetic */ ForumHorizonListCard ˊ;

        class d extends s {
            final /* synthetic */ b ʻॱ;
            private View ॱˋ;
            private View ॱᐝ;
            private View ᐝॱ;

            public d(b bVar, View view) {
                this.ʻॱ = bVar;
                super(view);
                this.ᐝॱ = view.findViewById(c.ˋˊ);
                this.ॱˋ = view.findViewById(c.ˊᐝ);
                this.ॱᐝ = view.findViewById(c.ˉ);
            }
        }

        private b(ForumHorizonListCard forumHorizonListCard) {
            this.ˊ = forumHorizonListCard;
        }

        @NonNull
        public s ˎ(@NonNull ViewGroup viewGroup, int i) {
            s dVar = new d(this, LayoutInflater.from(viewGroup.getContext()).inflate(o.bsy.b.ʽ, viewGroup, false));
            if (MinimumFactory.getBoolValue(ContentManager.getInstant().getContext())) {
                dVar.ˊ.setLayoutDirection(1);
            }
            return dVar;
        }

        public void ॱ(@NonNull s sVar, int i) {
            d dVar = (d) sVar;
            ForumHorizonListCardBean forumHorizonListCardBean = (ForumHorizonListCardBean) this.ˊ.ˌ();
            int size = forumHorizonListCardBean.ˊ().size();
            int i2 = i * 3;
            for (int i3 = 0; i3 < 3; i3++) {
                View view;
                if (i3 == 0) {
                    view = (ViewGroup) dVar.ᐝॱ;
                } else if (i3 == 1) {
                    view = (ViewGroup) dVar.ॱˋ;
                } else {
                    view = (ViewGroup) dVar.ॱᐝ;
                }
                LayoutParams layoutParams = (LayoutParams) view.getLayoutParams();
                if (layoutParams == null) {
                    view.setLayoutParams(new LayoutParams(this.ˊ.ʻ, -2));
                } else {
                    layoutParams.width = this.ˊ.ʻ;
                }
                int i4 = i2 + i3;
                if (i4 < size) {
                    view.setVisibility(0);
                    ForumHorizonListItemCard forumHorizonListItemCard = new ForumHorizonListItemCard(this.ˊ.ʼॱ);
                    forumHorizonListItemCard.ˏ(view);
                    CardBean forumFollowCardBean = new ForumFollowCardBean();
                    forumFollowCardBean.ˏ((Section) forumHorizonListCardBean.ˊ().get(i4));
                    forumHorizonListItemCard.ˏ(forumFollowCardBean);
                    forumHorizonListItemCard.ॱ(this.ˊ.ˏ);
                    if (i3 == 2 || i4 == size - 1) {
                        view.findViewById(c.ᐨ).setVisibility(4);
                    }
                } else if (i == 0) {
                    view.setVisibility(8);
                } else {
                    view.setVisibility(4);
                }
            }
        }

        public int ˏ() {
            CardBean ˌ = this.ˊ.ˌ();
            if (ˌ instanceof ForumHorizonListCardBean) {
                ForumHorizonListCardBean forumHorizonListCardBean = (ForumHorizonListCardBean) ˌ;
                if (forumHorizonListCardBean.ˊ() != null) {
                    return Double.valueOf(Math.ceil(((double) forumHorizonListCardBean.ˊ().size()) / 3.0d)).intValue();
                }
            }
            return 0;
        }
    }

    public /* synthetic */ ForumCard ˎ(View view) {
        return ˊ(view);
    }

    public /* synthetic */ cgz ˏ(View view) {
        return ˊ(view);
    }

    public ForumHorizonListCard(Context context) {
        super(context);
    }

    private int ʼ() {
        int dimensionPixelSize = this.ʼॱ.getResources().getDimensionPixelSize(e.ˏˏ);
        if (!ayy.ˋ().ˎ() || azb.ˎ(this.ʼॱ)) {
            return dimensionPixelSize;
        }
        return 0;
    }

    public ForumHorizonCard ˊ(View view) {
        int dimensionPixelSize;
        super.ˎ(view);
        this.ʽ = view.findViewById(c.ˎ);
        this.ʽ.setPaddingRelative(azb.ˊ(this.ʼॱ), this.ʼॱ.getResources().getDimensionPixelSize(e.ᐝॱ), azb.ˏ(this.ʼॱ), this.ʼॱ.getResources().getDimensionPixelSize(e.ॱˎ));
        RecyclerView ॱॱ = ॱॱ();
        int ˊ = azb.ˊ(this.ʼॱ);
        if (!ayy.ˋ().ˎ() || azb.ˎ(this.ʼॱ)) {
            dimensionPixelSize = this.ʼॱ.getResources().getDimensionPixelSize(e.ˏˏ);
        } else {
            dimensionPixelSize = this.ʼॱ.getResources().getDimensionPixelSize(e.ॱॱ);
        }
        ॱॱ.setPaddingRelative(ˊ, 0, dimensionPixelSize, 0);
        return this;
    }

    public void ˏ(CardBean cardBean) {
        super.ˏ(cardBean);
    }

    protected void ˎ() {
        int ॱ = ॱ(this.ʼॱ);
        int ˊ = azb.ˊ(this.ʼॱ) + this.ʼॱ.getResources().getDimensionPixelSize(e.ˏ);
        this.ʻ = (((((azb.ॱ(this.ʼॱ) - this.ˎ.ॱ()) - (ˊ * ॱ)) - (this.ˎ.ॱॱ() * (ॱ + 2))) / ॱ) + ˊ) + ʼ();
    }

    public View ʻ() {
        return this.ʽ;
    }

    protected a ᐝ() {
        return new b();
    }

    private int ॱ(Context context) {
        if (epv.ˏॱ(context)) {
            return 3;
        }
        if (epv.ʼ(context)) {
            return 1;
        }
        return 2;
    }
}
